//
//  LTStethoscopeSDK.h
//  hc21SDK
//
//  Created by lanzhongping on 2021/1/6.
//

#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>
#import "CADeviceInfo.h"
#import "CASdkConstant.h"
#import "CAEcgData.h"
#import "CAEcgAlgorithmResults.h"
#import "CAEcgParamObj.h"
#import "CANalgProtocal.h"
#import "CAnAlgGrandActivity2.h"
#import "CAnAlgGrandActivity.h"
#import "CAnAlgExerData.h"
#import "CAnAlgRealMeasure.h"
#import "CAnAlgRltExerData.h"
#import "CAPpgMeasureState.h"
#import "CAnAlgDevErrLog.h"
NS_ASSUME_NONNULL_BEGIN

@class CABLeService;
@class CAHistoryData;
@class CAHistoryDataSR03;
//@class SRDeviceInfo;

typedef NS_ENUM(UInt8, CAOTA_STATUS_VALUES) {
    // Value zero must not be used !! Notifications are sent when status changes.
    CAOTAR_SRV_STARTED      = 0x01,     // Valid memory device has been configured by initiator. No sleep state while in this mode
    CAOTAR_CMP_OK           = 0x02,     // SPOTA process completed successfully.
    CAOTAR_SRV_EXIT         = 0x03,     // Forced exit of SROTAR service.
    CAOTAR_CRC_ERR          = 0x04,     // Overall Patch Data CRC failed
    CAOTAR_PATCH_LEN_ERR    = 0x05,     // Received patch Length not equal to PATCH_LEN characteristic value
    CAOTAR_EXT_MEM_WRITE_ERR= 0x06,     // External Mem Error (Writing to external device failed)
    CAOTAR_INT_MEM_ERR      = 0x07,     // Internal Mem Error (not enough space for Patch)
    CAOTAR_INVAL_MEM_TYPE   = 0x08,     // Invalid memory device
    CAOTAR_APP_ERROR        = 0x09,     // Application error
    
    // SUOTAR application specific error codes
    CAOTAR_IMG_STARTED      = 0x10,     // SPOTA started for downloading image (SUOTA application)
    CAOTAR_INVAL_IMG_BANK   = 0x11,     // Invalid image bank
    CAOTAR_INVAL_IMG_HDR    = 0x12,     // Invalid image header
    CAOTAR_INVAL_IMG_SIZE   = 0x13,     // Invalid image size
    CAOTAR_INVAL_PRODUCT_HDR= 0x14,     // Invalid product header
    CAOTAR_SAME_IMG_ERR     = 0x15,     // Same Image Error
    CAOTAR_EXT_MEM_READ_ERR = 0x16,     // Failed to read from external memory device
    
};


typedef NS_ENUM(UInt8, EXCUTED_CMD) {
    EXCUTED_CMD_SET_SPORT_MODE = 0x01,         //运动模式设置
    EXCUTED_CMD_SET_HR_TEMP_MEASURE = 0x02,    // 体温 心率设置
    EXCUTED_CMD_SET_OXYGEN_MEASURE = 0x03,     //血氧测量设置
    EXCUTED_CMD_SYNC_TIME = 0x04,              // 时间同步
    EXCUTED_CMD_GET_OXYGEN_HRV = 0x05,         // 获取心率血氧
    EXCUTED_CMD_GET_STEPS = 0x06,              //获取计步
    EXCUTED_CMD_GET_TEMPERATURE = 0x07,        //获取体温
    EXCUTED_CMD_SHUT_DOWN = 0X08,              // 关机
    EXCUTED_CMD_REBOOT = 0X09,                 // 重启
  
    EXCUTED_CMD_FACTORY_RESET = 0x0a,          // 恢复出厂设置
    
    EXCUTED_CMD_HIS_COUNT = 0x0c,              // 历史数据个数
    EXCUTED_CMD_HIS_DATA = 0x0d,               // 历史数据
    EXCUTED_CMD_CLEAR_HIS_DATA = 0x0e,         // 清空历史
    EXCUTED_CMD_DEVICE_INFO = 0x0f,            // 设备信息
    EXCUTED_CMD_SN = 0x10,                     // sn
    EXCUTED_CMD_BATTERY = 0X11,                // 电池电量
    EXCUTED_CMD_BIND = 0X15,                   // 绑定解绑设备
    EXCUTED_CMD_START_MANUFACT_CER = 0x1B,     // 开始厂家验证
    EXCUTED_CMD_MANUFACT_SEND_R2 = 0x1C,       // 向设备发送解密原文
    EXCUTED_CMD_MODIFY_BRCAST_NAME = 0x1D,     // 修改广播名称
    EXCUTED_CMD_SPORT_MODE = 0x20,             // 运动模式

    EXCUTED_CMD_FUNCTIN_SWITCH = 0x31,         // 设备功能开关
    EXCUTED_CMD_FUNCTIN_SET_HR_MEASURE_DURATION = 0x3C, // 设置测量时长
    EXCUTED_CMD_FUNCTIN_GET_DEVICEINFO_5 = 0x3d, // 获取设备信息5 心率测量时长 回包0x8f
    
    EXCUTED_CMD_FUNCTIN_ECG = 0x52,             // 仅sr23可用
    EXCUTED_CMD_FUNCTIN_ECG_PPG = 0x53,         // 仅sr23可用
    // sr28 cm设备
    EXCUTED_CMD_SET_USERINFO = 0x58, //设置用户信息到设备,
    EXCUTED_CMD_START_CM_EXER = 0x59, //开启/关闭 暂停 恢复 CM锻炼
    
    EXCUTED_CMD_GET_HISCNT_ACT_SWIM_SLEEP  = 0x5A, // 获取活动检测/游泳/睡眠历史数据数量
    EXCUTED_CMD_GET_HIS_DATA_ACT_SWIM_SLEEP  = 0x5B, // 获取活动检测/游泳/睡眠历史数据
    EXCUTED_CMD_GET_LAST_ACTIVITY = 0x5C, //获取最后的活动 应答0xC8

    EXCUTED_CMD_CLEAN_ACTIVITY_DATA = 0x5E, // 清空活动历史数据
    EXCUTED_CMD_EXER_REALTM_REPORT = 0x5F, // 锻炼数据实时上报
    EXCUTED_CMD_CM_MEA_DURA_AND_TIME = 0x60, // 设置/查询 cm设备 测量时间和测量间隔时间

    EXCUTED_CMD_CM_DEVICE_ALGORITHM = 0x61, // 设置/查询 设备算法类型
    
    EXCUTED_CMD_FUNCTIN_LED_MEA = 0x63,  // Monochrome LED measurement PPG measurement, for blood sugar and blood pressure

    
};// 下发命令字



//typedef NS_ENUM(NSUInteger, REALTIME_STATUS) {
//    REALTIME_STATUS_NO_MEASURE = 0x00,
//    REALTIME_STATUS_MEASURING = 0x01,
//    REALTIME_STATUS_DATA_USEFUL = 0x02,
//};


//typedef NS_ENUM(uint8_t, SOS_DOUBLESLAP_INTERVAL_TYPE) {
//    INTEVAL_50MS =  0x00,   // 50ms
//    INTEVAL_100MS = 0x01,   //100ms
//    INTEVAL_150MS = 0x2,    //150ms
//    INTEVAL_200MS = 0x3,    //200ms
//    INTEVAL_250MS = 0x4,    //250ms
//    INTEVAL_375MS = 0x5,    //375ms
//    INTEVAL_500MS = 0x6,    //500ms
//    INTEVAL_700MS = 0x7,    //700ms
//    
//};

typedef NS_ENUM(uint32_t, CACS_DEV_MEA_DURA_AND_TM_TYPE) {
    CACS_DEV_MEA_DURA_AND_TM_TYPE_A, // Heart rate/HRV/respiration rate/temperature measurement (心率/HRV/呼吸率/温度测量)
    CACS_DEV_MEA_DURA_AND_TM_TYPE_B,// Spo2 measurement
};

typedef NS_ENUM(uint8_t, CA_NALG_SWIM_POOL_SIZE) {
    CASWIM_POOL_UKONW = 0x00,
    CASWIM_POOL_SIZE_A = 0x01,   // 25m
    CASWIM_POOL_SIZE_B = 0x02,   // 50m
};


typedef NS_ENUM(uint8_t, CAEXER_SUB_CMD) {
    CAEX_STOP = 0,
    CAEX_START = 1,
    CAEX_PAUSE = 2,
    CAEX_CONTINUE = 3,
};

typedef NS_ENUM(uint8_t, CA_UPD_ERROR) {
    CA_UPGRADE_ERROR_FORCE_EXIT_OF_UPGRADE_SERVICE = 0x03, //Forced exit of SPOTA service.
    CA_UPGRADE_ERROR_PATH_DATA_CRC_MISMATCH = 0x04, //Patch Data CRC mismatch.
    CA_UPGRADE_ERROR_PATH_LENGTH_MISMATCH = 0x05 ,//Received patch Length not equal to PATCH_LEN characteristic value.
    CA_UPGRADE_ERROR_EXTERNAL_MEMORY_ERROR = 0x06, //External Memory Error. Writing to external device failed.
    CA_UPGRADE_ERROR_INTERNAL_MEMORY_ERROR = 0x07 ,//Internal Memory Error. Not enough internal memory space for patch.
    CA_UPGRADE_ERROR_INVALID_MEMORY_DEVICE = 0x08 ,//Invalid memory device.
    CA_UPGRADE_ERROR_APPLICATION_ERROR = 0x09 ,//Application error.
    CA_UPGRADE_ERROR_INVALID_IMAGE_BANK = 0x11 ,//Invalid image bank.
    CA_UPGRADE_ERROR_INVALID_IMAGE_HEADER = 0x12 ,//Invalid image header.
    CA_UPGRADE_ERROR_INVALID_IMAGE_SIZE = 0x13 ,//Invalid image size.
    CA_UPGRADE_ERROR_INVALID_PRODUCT_HEADER = 0x14 ,//Invalid product header.
    CA_UPGRADE_ERROR_SAME_IMAGE = 0x15 ,//Same Image Error.
    CA_UPGRADE_ERROR_READ_EXTERNAL_MEMORY_DEVICE_FAILED = 0x16 ,//"Failed to read from external memory device."
    
};
/* about ble device scan and connect */
@protocol CABleScanProtocal <NSObject>

@optional

/// scan device list fresh
/// @param perphelArray  scaned devices
-(void)caScanDeviceDidRefresh:(NSArray<CABLeService *> *)perphelArray;


/// phone ble power state change
/// @param isOn  YES = power On , NO = power off
- (void)caBlePowerStateChange:(CBManagerState)state;



@end

/* about ble data translate */
@protocol CABleDataProtocal <NSObject>

- (void)caBleDidConnectPeripheral:(CABLeService*)service;
- (void)caBleDidDisconnectPeripheral:(CABLeService*)service;
- (void)caBleFailConnectPeripheral:(CBPeripheral *)peripheral Error:(NSError *)error;



/// perphel is ready for read write
/// @param service current connect devices
- (void)caBleDeviceDidReadyForReadAndWrite:(CABLeService*)service;



/// call back value of hrv
/// @param hrv hrv
- (void)caBleRealtimeHRV:(NSNumber *)hrv BloodOxygen:(NSNumber *)bloodOxygen HeartRate:(NSNumber *)hr Status:(REALTIME_STATUS)status;


/// call back device's battery level and charging state.
/// After the ring is connected to Bluetooth, the ring will automatically report the battery level
/// at a fixed time, and this interface will be automatically called back.
/// @param batteryLevel battery level
/// @param isCharging YES = device is charging
- (void)caBleDeviceBatteryLevel:(NSInteger)batteryLevel IsCharging:(BOOL)isCharging;


/// call back value of device's sn code
/// @param sn sn code
- (void)caBleSN:(NSString *)sn SnData:(NSData *)snData;

- (void)caBleDeviceInfo:(CADeviceInfo *)devInfo;




/// call back realtime steps
/// @param steps steps
- (void)caBleDeviceRealtimeSteps:(NSNumber *)steps IsDeviceFix:(BOOL)isDeviceFixed;


/// call back realtime skin temperature
/// @param temperature skin temperature Unit(℃)
- (void)caBleDeviceRealtimeTemperature:(NSNumber *)temperature;


/// call back for excute result of sended command
/// @param cmd  sended cmd
/// @param isSucc YES = success
- (void)caBleCmdExcute:(EXCUTED_CMD)cmd Succ:(BOOL)isSucc Reason:(CA_CMD_EXECTE_ERROR_REASON)reason Data:(NSData *)originData;


/// 返回历史数据条目
/// @param count 历史数据数量
- (void)caBleHistoryDataCount:(NSInteger)count;

/// gain device's cache data time out
- (void)caBleHistoryDataTimeout;


/// call back value of history data 1
/// @param hisData : Encapsulated data. If the "caBleHistoryDataCount" callback count is 0, the hisData callback value is nil, and the isComplete callback value is YES.
/// @param isComplete YES = translate finish
- (void)caBleHistorySr03Data:(CAHistoryDataSR03 * _Nullable)hisData IsComplete:(BOOL)isComplete;


//- (void)srBleOtherInfo:(BOOL)isSosOpen
//          DoubleTapTimes:(uint8_t)doubleTapTimes
//       SingleTapInterval:(SOS_DOUBLESLAP_INTERVAL_TYPE)singleTapInterval TapDetectionThreshold:(uint8_t)tapDetectionThreshold
//DoubleTapEffectStartTime:(uint8_t)doubleTapEffectStartTime DoubleTapEffectEndTime:(uint8_t)doubleTapEffectEndTime Isbinded:(BOOL)isBinded;

/// Callback reporting whether the device is bound
/// @param isBinded -- YES=bound, NO=unbind
- (void)caBleIsBinded:(BOOL)isBinded;





/* OEM AUTH */

/// oem认证结果回调
/// @param authSucceddful 认证成功=YES
- (void)caBleOEMAuthResult:(BOOL)authSucceddful;

/// 设备每次测量时长上报
/// - Parameter seconds: measuration druration
-(void)caBleMeasureDuration:(NSInteger)seconds;


@optional

// 回调计步阈值 设备协议2.3
-(void)caBleStepCountThreshold:(uint8_t)threshold;
// 回调ecg波形
-(void)caBleEcgWave:(CAEcgData *)ecgObj;

// ecg+ ppg混合
//-(void)srBleEcgAndPPg:(SrEcgData *)ecgPpgObj;
-(void)caBleEcgAndPPgWave:(CAEcgData *)ecgPpgObj;

// 回调ecg计算结果
-(void)caBleEcgAlgorithmResult:(CAEcgAlgorithmResults *)ecgResult;

// 手指接触
-(void)caBleEcgEcgLeadOn:(BOOL)leadOn;


// 单色led测量数据回调
-(void)caLedPPgDataRep:(NSMutableArray<NSNumber *> *)dataArry;

// led单测状态 下发0x63 回调
-(void)caLedStateReport:(BOOL)on Led:(uint8_t)led Current:(uint8_t)current AutoDim:(uint8_t)autoDim Freq:(uint8_t)freq;

-(void)caPPGMeasuState:(CAPpgMeasureState *)stateObj;


/** CM SR28设备回调 **/

/// User information reporting
/// - Parameters:
///   - gender:  0 male, 1 female
///   - ageYear: range 1-115
///   - height:  in mm, range 1200-3000
///   - weight:  in kg, range 30-200
-(void)caBleUsrInfoFromoDev:(NSUInteger)gender
                Age:(NSUInteger)ageYear
              Height:(NSUInteger)height
                     Weight:(NSUInteger)weight;

-(void)caBleNALGDevMeaDuration:(CACS_DEV_MEA_DURA_AND_TM_TYPE)meaType MeaDuraofNoSlepPerd:(uint32_t)meaduraNoSleep MeaIntervOfNoSlepPerd:(uint32_t)meaIntervNoSleep
      MeaDuraofInSlepPerd:(uint32_t)meaduraInSleep MeaIntervInNoSlepPerd:(uint32_t)meaIntervInSleep;


/// 上报算法类型 0-linkgtop算法 1-CM算法
-(void)caBleNALGalgorithmType:(uint8_t)algorithmType;


/// sr28实时测量数据
/// - Parameter realMeasurData: 实时测量数据
-(void)caBleNALGRealMeasu:(CAnAlgRealMeasure *)realMeasurData;

/// Report the number of activity detection/swimming/sleep history data
/// - Parameters:
///   - count: The amount of data
///   - minUUid: The minimum uuid of the data reported this time
///   - maxUUid: The maximum uuid of the data reported this time
-(void)caBleHisCntOfActivityAndSwimAndSleep:(NSUInteger)count MinUUid:(uint32_t)minUUid MaxUUid:(uint32_t)maxUUid;

// Callback Report activity detection/exercise/new historical data/body temperature historical data/sleep data
-(void)caBleNalgDeviceMeasurHinstoryData:(id<CANalgProtocal>)dataObj;

// cm锻炼实时上报
-(void)caBleNalgRealtimeWorkoutData:(CAnAlgRltExerData *)nalgExerRltData;

// 下发0x5c单词回调
-(void)caBleLastActivity:(CAnAlgGrandActivity*)activity;

// 下发0x68 单次回调
-(void)caBleLastActivity2:(CAnAlgGrandActivity2 *)activity2;
/** CM **/


@end


@protocol CAOTAProtocal <NSObject>


/// 错误回调
/// @param errorCode 错误码
-(void)caOtaError:(CAOTA_STATUS_VALUES)errorCode;
-(void)caOtaFinish:(BOOL)isSuccessful;
-(void)caOtaUpdateProgress:(float)progress;

@end



@interface CARingSDK : NSObject

@property(weak, nonatomic)id<CABleScanProtocal> blescanDelegate;
@property(weak, nonatomic)id<CABleDataProtocal> bleDataDelegate;
@property(weak, nonatomic)id<CAOTAProtocal> bleOtaDelegate;  // ota 代理回调对象

+(instancetype)instance;

// 没有别的用, 就是初始化一下sdk
-(void)registWithCompanyArray:(NSArray<NSString *>  * _Nullable )cpArray;
-(void)registECGKey:(NSString *)key Secret:(NSString *)secret;
-(BOOL)hasECGKeyAndSecret;

-(void)setBroadCastAnalyCids:(NSArray<NSArray<NSNumber *> *> *)cidArray;

-(NSArray<NSArray<NSNumber *> * > *)broadCastAnalyCids;

-(void)setCurrentPeripheralService:(CABLeService* _Nullable)peripheralService;

-(NSString *)sdkVersion;

-(NSString *)netKey;
-(NSString *)netSecret;


-(NSString *)signStringWith:(NSString *)sn MacAddr:(NSString *)mac;


// iOS ble state
- (CBManagerState)bleCenterManagerState;

-(void)startBleScanWithOption:(NSDictionary * _Nullable)option;
-(void)stopBleScan;
-(void)connectDevice:(CABLeService *)device;
-(void)disconnectCurrentService;

-(CAEcgParamObj *)ecgParamObj;


// 当前已连接的设备
-(CABLeService *)currentDevice;

/// send cmd to get oxygen and hrv data
/// @param isStart   NO=off   yes=on
-(void)functionOxygenAndHrvBoth:(BOOL)both IsOpen:(BOOL)isStart;



/// send cmd to power off device
-(void)functionShutDownDevice;


/// send cmd to reboot device
-(void)functionRebootDevice;

/// get device's battery
/// "- (void)caBleDeviceBatteryLevel:(NSUInteger)batteryLevel IsCharging:(BOOL)isCharging" will
/// call back
-(void)functionGetDeviceBattery;


/// get steps
-(void)functionGetStepsOnce;


/// get skin temperature
-(void)functionGetTemperatureOnce;


/// device reset to factory status
-(void)functionDeviceReset;


/// get device's SN code
/// "- (void)caBleSN:(NSString *)sn SnData:(NSData *)snData" will call back.
/// "- (void)caBleIsBinded:(BOOL)isBinded" will call back.
/// "- (void)caBleOEMAuthResult:(BOOL)authSucceddful;" will call back
-(void)functionGetDeviceSN;

/// get device's infomation
-(void)functionGetDeviceInfo;



/// get device's cache history data
/// retrun YES = cmd send successful  retrun NO = the last history data process is translating
-(BOOL)functionGetHistoryData;

/// clear device's history data cache
-(void)functionClearDeviceHistoryCache;


/// 直接获取数据 用于设备测量中的延迟获取
-(void)functionGetHistoryDataOnlyData;

-(void)functionRsetTranslatingHistoryState;


///
/// @param bind YES = bind device NO = unbine device
-(void)functionSetBindeDevice:(BOOL)bind;


/// Set the ring's OEM verification switch
/// @param on :YES = turn on, NO = turn off
-(void)functionSetOEMAuthSwitch:(BOOL)on;


/// 开启运动模式
/// @param durationMinutes 持续时间 单位:分钟 范围(5min - 180min)
/// @param valueInterval 设备取值间隔 秒

//-(void)functionStartSportMode:(uint16_t)durationMinutes ValueInterval:(uint16_t)valueInterval WorkType:(WORKOUT_TYPE)wkType;


/// 手动关闭运动模式
-(void)functionShutdownSportMode;


/// 获取当前设备测量时长
-(void)functionGetDeviceMeasureDuration;


/// 设置当前设备测量时长
/// - Parameter duration: 单位 秒
-(void)functionSetDeviceMeasureDuration:(NSInteger)duration;

// 血糖的ppg测量 will callback from: caLedPPgDataRep
//-(void)functionTurnGlucosePPgMeasure:(BOOL)on;

-(void)functionLedMeasure:(BOOL)on LedColor:(uint8_t)ledColor AutoAdjBri:(BOOL)autoAdjBri Current:(uint8_t)current SampleRate:(uint8_t)sampleRate;


/// ecg测量
/// - Parameter on: YES 开 NO 关
///
-(BOOL)functionECGMeasure:(BOOL)on Param:(CAEcgParamObj * _Nullable)paramObj DispSrc:(BOOL)isFilterWave;

/// ecg和ppg同时测量
/// - Parameter on: YES 开 NO 关
-(void)functionEcgAndPpgMeasure:(BOOL)on;



/// 同步设备的时间
/// - Parameter date: 时间
-(void)functionSyncTime:(NSDate *)date;


/// 设置计步阈值
/// - Parameter threshold:  计步阈值范围为：0x0-0x3F
//-(void)functionSetStepCountingThreshold:(uint8_t)threshold;

/**  About OTA **/

-(void)functionStartOta:(NSURL *)fileUrl;

/**  About OTA **/

/* CM */

/// Set user information
/// - Parameters:
///   - gender: Gender: 0 male, 1 female
///   - ageYear: Age: range 1-115
///   - height: Height: in mm, range 1200-3000
///   - weight: Weight: in kg, range 30-200
-(BOOL)functionSetUsrInfoToDev:(NSUInteger)gender
                           Age:(NSUInteger)ageYear
                         Height:(NSUInteger)height
                        Weight:(NSUInteger)weight;

/// Modify Bluetooth broadcast name
/// - Parameter name: Broadcast name. Length > 0 && Length <= 16
/// - Parameter hideMac:NO=The broadcast name will display an underscore and the last two digits of the MAC address.
///                     YES=YES = the broadcast name will hide the underscore and the last two digits of the MAC address.
-(BOOL)functionModifyBRcastName:(NSString *)name HideMac:(BOOL)hideMac;

/// Get user information
/// Callback from the following api: "caBleUsrInfoFromoDev:Age:Height:Weight:"
-(BOOL)functionGetUsrInfoFromDev;

/// Get the latest events(获取最新活动),Callback from interface "-caBleLastActivity:"
-(BOOL)functionGetLastActivity;

/// Get the latest events2, Callback from interface "-caBleLastActivity2:"
-(BOOL)functionGetLastActivity_2;

/// Get the number of activity detection/swimming/sleep history data (获取活动检测/游泳/睡眠历史数据数量)
/// Callback interface:"caBleHisCntOfActivityAndSwimAndSleep:MinUUid:MaxUUid:"
-(BOOL)functionGetHistoryCntOfActvtyDtctAndSwimAndSleepHisty;

/// Get activity detection/swimming/sleep history data (获取活动检测/游泳/睡眠历史数据)
/// Callback interface: caBleNalgDeviceMeasurHinstoryData:
///  The types of reports that will be issued include:(0x5b下发以后上报的类型:)
/// CAHistoryDataNALG       // 0xc1
/// CAnAlgAutoDetecActivity // 0xc3
/// CAnAlgAutoDetecSWim     // 0xc4
/// CAnAlgExerData          // 0xc5
/// CAnAlgSwimSumData       // 0x0xc6
/// CAnAlgSwimLapData       // 0x0xc7
/// CAnAlgSleep             // 0xc9
/// CAnAlgGrandActivity     // 0xca
/// CAnAlgExerVitalSignsData  // 0xcc
-(BOOL)functionGetHstryDataOfActvtyDetectAndSwimAndSlep; // 0x5B


/// Get part of activity detection/swimming/sleep history data (获取活动检测/游泳/睡眠历史数据)
/// Callback interface: caBleNalgDeviceMeasurHinstoryData:
///  The types of reports that will be issued include:(0x5b下发以后上报的类型:)
/// CAHistoryDataNALG       // 0xc1
/// CAnAlgAutoDetecActivity // 0xc3
/// CAnAlgAutoDetecSWim     // 0xc4
/// CAnAlgExerData          // 0xc5
/// CAnAlgSwimSumData       // 0x0xc6
/// CAnAlgSwimLapData       // 0x0xc7
/// CAnAlgSleep             // 0xc9
/// CAnAlgGrandActivity     // 0xca
/// CAnAlgExerVitalSignsData  // 0xcc
/// - Parameters: maxUUid The maximum index of the data uuid that needs to be obtained
-(BOOL)functionGetHstryDataOfActvtyDetectAndSwimAndSlepMaxUUid:(uint32_t)maxUUid;


/// Clear activity history data.(清空活动历史数据)
-(BOOL)functionCleanActivityHistory;

/// Set the measurement interval and duration of the new algo device(设置CM设备测量间隔和时长)
/// call back: "caBleNALGDevMeaDuration:MeaDuraofNoSlepPerd:MeaIntervOfNoSlepPerd:MeaDuraofInSlepPerd: MeaIntervInNoSlepPerd:"
/// - Parameters:
///   - meaType: 测量类型 0-心率/HRV/呼吸率/温度测量 1-血氧测量
///   - meaduraNoSleep: The measured duration of the non-sleep period(非睡眠时间段的测量时长)
///   - meaIntervNoSleep: Measurement interval during non-sleep period(非睡眠时间段的测量间隔时长)
///   - meaduraInSleep: Measured duration of sleep periods(睡眠时间段的测量时长)
///   - meaIntervInSleep: Measurement interval during sleep(睡眠期间的测量间隔)
-(BOOL)functionSetNalgDevMeaDuration:(CACS_DEV_MEA_DURA_AND_TM_TYPE)meaType MeaDuraofNoSlepPerd:(uint32_t)meaduraNoSleep MeaIntervOfNoSlepPerd:(uint32_t)meaIntervNoSleep
                       MeaDuraofInSlepPerd:(uint32_t)meaduraInSleep MeaIntervInNoSlepPerd:(uint32_t)meaIntervInSleep;

/// Get the measurement interval and duration of the new algothm device
/// - Parameters:
/// - meaType: Measurement type 0-heart rate/HRV/respiration rate/temperature measurement 1-blood oxygen measurement.(测量类型 0-心率/HRV/呼吸率/温度测量 1-血氧测量)
/// callback:"caBleNALGDevMeaDuration:MeaDuraofNoSlepPerd:MeaIntervOfNoSlepPerd:MeaDuraofInSlepPerd: MeaIntervInNoSlepPerd:"
-(BOOL)functionGetNalgDevMeaDuration:(CACS_DEV_MEA_DURA_AND_TM_TYPE)meaType;



///  Start exercise
/// - Parameters:
///   - execType: Types of Exercise
///   - sizeType: Pool length, only valid when the type is swimming, for other types of sports, fill in SWIM_POOL_UKONW
///   - duraMins: Estimated duration of exercise, uint: minute
-(BOOL)functionStartNalgExerciseWithType:(NALG_EXERCISE_TYPE)execType PoolSize:(CA_NALG_SWIM_POOL_SIZE)sizeType DurationMins:(uint16_t)duraMins;

// 继续锻炼
-(BOOL)functionContinueNalgExercise;

// 暂停锻炼
-(BOOL)functionPauseNalgExercise;

// 停止锻炼
-(BOOL)functionStopNalgExercise;




/// Switch to report activity data during exercise(实时上报锻炼期间的活动数据的开关)
/// - Parameter on: YES=turn on NO = off
-(BOOL)functionNalgRealtimeReportDurinExerciseSwitch:(BOOL)on;

/// 设置戒指算法
/// - Parameter algorithmType: 0-本地算法、1-三方算法
-(BOOL)functionNalgSetDeviceAlgorithm:(uint8_t)algorithmType;


/// 获取戒指当前算法
-(BOOL)functionNalgGetDeviceAlgorithm;


/* CM */

- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;

@end

NS_ASSUME_NONNULL_END
